@REM 对 hex 文件添加版本信息
@echo off

SETLOCAL
set input_file=%~1

call %g_bat_dir_path%\readini.bat %g_config_file_path% option isCropHexFile isCropHexFile

@if not defined isCropHexFile (
	@echo Warning: .ini file [option: isCropHexFile] does not set param
	exit /B 0
)

@if %isCropHexFile% equ 0 (
	@echo not need crop hex file
	@exit /B 0
)

call %g_bat_dir_path%\readini.bat %g_config_file_path% file hexFileAddr hexFileAddr
call %g_bat_dir_path%\readini.bat %g_config_file_path% file hexFileSize hexFileSize

@set /a hexFileEnd=%hexFileAddr%+%hexFileSize%

@set output_file=crop_%input_file%
set input_file_name=%input_file%.hex
set output_file_name=%output_file%.hex

@%g_exe_dir_path%\srec_cat.exe %g_obj_dir_path%\%input_file_name% -intel -crop %hexFileAddr% %hexFileEnd% -o %g_obj_dir_path%\%output_file_name% -intel
@echo %input_file_name% crop generate %output_file_name%

(endlocal
set %~2=%output_file%
)
ENDLOCAL
exit /B 0